home *** CD-ROM | disk | FTP | other *** search
- /* Copyright, 1990, Regents of the University of Colorado */
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include <sys/types.h>
- #include <sys/param.h>
- #include <ctype.h>
- #include <sys/stat.h>
- #include <sys/timeb.h>
- #include <sys/wait.h>
- #include <malloc.h>
- #include <errno.h>
- #include <varargs.h>
- #include <fcntl.h>
- #include <dirent.h>
- #include <utime.h>
-
- #define BOOL char
- #define TRUE 1
- #define FALSE 0
-
- #define MAXLINESIZE 256
- #define MAXMACHINES 10
- #define MAXMACHNAME 20
- #define NAMESIZE 15
- #define BUFSIZE 2048
-
- extern void exit();
- extern char *getenv();
-
- static int get_yn();
- static void get_line();
- static int get_line_quit();
- static void copy();
- static void copyerr();
- static void maked();
-
- #include "messages.h"
-
- /********************************************************************
- *
- * List of FATAL SYSTEM ERRORS:
- *
- * 1: No "USER" environment variable found.
- *
- * 2: No "PATH" environment variable found.
- *
- * 3: No "PWD" environment variable found.
- *
- * 4: Unable to open existing "dino.init" file for reading.
- *
- * 5: Unable to set up pipe for redirecting stdout and stderr.
- *
- * 6: Unable to open new file (. . .) for writing.
- *
- * 7: Unable to open existing "D..." files in /source/install
- * for reading.
- *
- * 8: Unable to create directory.
- *
- * 9: Unable to copy file.
- *
- * 10: Unable to establish symbolic link.
- *
- * 11: Unable to determine architecture type.
- *
- *******************************************************************/
-
- main()
- {
- int I, J;
- char enter[MAXLINESIZE], line[MAXLINESIZE];
- char dir[MAXPATHLEN], name[MAXPATHLEN], name2[MAXPATHLEN];
- char targetd[MAXPATHLEN], sourced[MAXPATHLEN];
- char target[NAMESIZE];
- char sim1loc[MAXPATHLEN], sim2loc[MAXPATHLEN];
- struct stat buf1, buf2;
- FILE *init, *input, *testf, *output;
- BOOL update = FALSE;
- BOOL newarch = FALSE;
- BOOL source = TRUE;
- BOOL pc = FALSE;
- BOOL partial = FALSE;
- BOOL bingo = FALSE;
- BOOL malformed;
- BOOL restart, done;
- BOOL sim1 = FALSE, sim2 = FALSE, grail = FALSE;
- BOOL local2 = FALSE;
- BOOL backend = TRUE;
- char *path, *current, *arch, *user;
- char *cptr1, *cptr2, *cptr3, *cptr4;
- char holder, inst_type;
- int M = 0;
- int tempi, fdes[2];
- int choice;
- int dfalt = 0;
- int status;
-
- static struct {
- char name[MAXMACHNAME];
- char address[MAXPATHLEN];
- char user[NAMESIZE];
- char directory[MAXPATHLEN];
- char rmt_directory[MAXPATHLEN];
- char lcl_directory[MAXPATHLEN];
- char rmt_user[NAMESIZE];
- char rmt_install;
- char type;
- int maxdim;
- int dim;
- char rcp;
- char rsh;
- char run;
- char date;
- BOOL xmt;
- BOOL home;
- BOOL install;
- } machines[MAXMACHINES];
-
-
- /* Print out the initial message. */
-
- (void) fprintf(stderr, "%s", messages[0]);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(0);
-
- /* First, check that DINO is properly installed. */
-
- (void) fprintf(stderr,
- "\n\n Checking the DINO system defaults . . .\n\n");
-
- /* Make sure the "ARCHTYPE" variable is set correctly. */
-
- if ((arch = getenv("ARCHTYPE")) != NULL)
- {
- if (strcmp(arch, "sun3") != 0 && strcmp(arch, "sun4") != 0)
- {
- (void) fprintf(stderr,"%s\"%s\".\n%s",
- messages[72], arch, messages[73]);
- exit(1);
- }
- }
- else
- {
- if (pipe(fdes))
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if (fork())
- {
- (void) wait(NULL);
- arch = malloc((unsigned) NAMESIZE);
- tempi = read(fdes[0], arch, MAXLINESIZE);
- if (arch[tempi-1] == '\n')
- arch[tempi-1] = '\0';
- else
- arch[tempi] = '\0';
- (void) close(fdes[0]);
- (void) close(fdes[1]);
- }
- else
- {
- (void) dup2(fdes[1], 1);
- (void) execlp("/usr/bin/arch", "arch", 0);
- }
- (void) fprintf(stderr, "%s", messages[1]);
- }
- if (strcmp(arch, "sun3") != 0 && strcmp(arch, "sun4") != 0)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 11; contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
-
-
- if ((user = getenv("USER")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 1: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if ((path = getenv("PATH")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 2: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if ((current = getenv("PWD")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 3: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if (strncmp(current, "/tmp_mnt", 8) == 0)
- {
- for (I = 8; current[I] != '\0'; I++)
- current[I-8] = current[I];
- current[I-8] = '\0';
- (void) fprintf(stderr, "%s", messages[66]);
- }
-
- /* Find out if the user has write permission here. */
-
- if ((testf = fopen("_D_TEST", "w")) == NULL)
- {
- (void) fprintf(stderr,
- " DINO is not able to write into %s\n", current);
- (void) fprintf(stderr,
- " This is probably because %s does not have write permission here.\n\n",
- user);
- (void) fprintf(stderr,
- " When you have fixed this problem, run \"install\" again.\n\n");
- return(0);
- }
- else
- {
- (void) fclose(testf);
- (void) unlink("_D_TEST");
- }
-
- /* Find out if there is a Pascal compiler in the path. */
-
- for (cptr1 = cptr2 = path; *cptr2 != '\0'; cptr2++, cptr1 = cptr2)
- {
- for (; *cptr2 != '\0' && *cptr2 != ':'; cptr2++);
- for (cptr3 = cptr1, cptr4 = &(name[0]);
- cptr3 != cptr2; cptr4++, cptr3++)
- *cptr4 = *cptr3;
- *(cptr4++) = '/';
- *(cptr4++) = 'p';
- *(cptr4++) = 'c';
- *(cptr4++) = '\0';
- if (stat(name, &buf1) == 0)
- {
- if (S_ISREG(buf1.st_mode) && (buf1.st_mode & S_IXOTH))
- {
- pc = TRUE;
- break;
- }
- }
- }
-
- /* Find out if there is a compiler executable here and if
- it is newer than any compiler source files. */
-
- (void) sprintf(name, "%s/bin/%s/d.exe", current, arch);
- if (stat(name, &buf1) == 0)
- {
- (void) sprintf(name, "%s/source/compiler/walk.p", current);
- if (stat(name, &buf2) == 0)
- {
- if (buf2.st_mtime > buf1.st_mtime)
- {
- if (!pc)
- {
- partial= TRUE;
- (void) fprintf(stderr, "%s", messages[2]);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- {
- (void) fprintf(stderr,
- "\n\n When you have fixed this problem, run \"install\" again.\n\n");
- return(0);
- }
- else
- {
- (void) fprintf(stderr,"\n\n");
- source = FALSE;
- }
- }
- }
- else
- source = FALSE;
- }
- else
- source = FALSE;
- }
- else
- {
- if (!pc)
- {
- (void) fprintf(stderr, "%s", messages[3]);
- return(0);
- }
- }
-
-
- if (partial)
- {
- (void) fprintf(stderr,
- " All DINO system defaults are correct\n");
- (void) fprintf(stderr,
- " (except the missing Pascal compiler).\n\n\n");
- }
- else
- (void) fprintf(stderr,
- " All DINO system defaults are correct.\n\n\n");
-
- /* Determine if this is a new installation or an update. */
-
- if (stat("bin/local/dino.init", &buf1) == 0)
- {
- if ((init = fopen("bin/local/dino.init", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 4: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- update = TRUE;
-
- /* Determine if we are installing
- the other architecture (sun3 or sun4) */
-
- (void) sprintf(name, "bin/%s/dino", arch);
- if (stat(name, &buf1) != 0)
- newarch = TRUE;
-
-
- /* If so, get the existing system configuration from dino.init. */
-
- for (holder = ' ';;)
- {
- if (holder == EOF) break;
- holder = getc(init);
- if (holder == '#')
- {
- for (; (holder = getc(init)) != '\n' && holder != EOF;);
- continue;
- }
- for (; holder != 'D' && holder != EOF && holder != '\n';
- holder = getc(init));
- if (holder == EOF) break;
- if (holder == '\n') continue;
- if (getc(init) != 'm')
- {
- for (; (holder = getc(init)) != '\n' && holder != EOF;);
- continue;
- }
- if (getc(init) != 'a')
- {
- for (; (holder = getc(init)) != '\n' && holder != EOF;);
- continue;
- }
- if (getc(init) != 'c')
- {
- for (; (holder = getc(init)) != '\n' && holder != EOF;);
- continue;
- }
- if (getc(init) != 'h')
- {
- for (; (holder = getc(init)) != '\n' && holder != EOF;);
- continue;
- }
- if (getc(init) != 's')
- {
- for (; (holder = getc(init)) != '\n' && holder != EOF;);
- continue;
- }
- if (getc(init) != '=')
- {
- for (; (holder = getc(init)) != '\n' && holder != EOF;);
- continue;
- }
- if (getc(init) != '"')
- {
- for (; (holder = getc(init)) != '\n' && holder != EOF;);
- continue;
- }
- for (;;)
- {
- malformed = FALSE;
- if (fscanf(init, " %s %s %s %s %c%d%c%c%c%c%d",
- machines[M].name,
- machines[M].address,
- machines[M].user,
- machines[M].directory,
- &machines[M].type,
- &machines[M].maxdim,
- &machines[M].rcp,
- &machines[M].rsh,
- &machines[M].run,
- &machines[M].date,
- &machines[M].dim) != 11)
- malformed = TRUE;
- if (machines[M].name[0] =='#' ||
- machines[M].address[0] =='#' ||
- machines[M].user[0] =='#' ||
- machines[M].directory[0] =='#')
- malformed = TRUE;
- switch (machines[M].type)
- {
- case 's':
- case 'S':
- case '1':
- case '2':
- case '8':
- case 'G': break;
- default: malformed = TRUE;
- }
- switch (machines[M].rcp)
- {
- case 'T':
- case 'F': break;
- default: malformed = TRUE;
- }
- switch (machines[M].rsh)
- {
- case 'T':
- case 'F': break;
- default: malformed = TRUE;
- }
- switch (machines[M].run)
- {
- case 'T':
- case 'F':
- case 'S': break;
- default: malformed = TRUE;
- }
- switch (machines[M].date)
- {
- case 'T':
- case 'F': break;
- default: malformed = TRUE;
- }
-
- if (malformed)
- {
- (void) fprintf(stderr, "%s", messages[4]);
- return(0);
- }
- M++;
- for (; (holder = getc(init)) == ' ' || holder == '\t';);
- if (holder == '"')
- {
- bingo = TRUE;
- break;
- }
- if (holder != '\\')
- (void) ungetc(holder, init);
- }
- if (bingo) break;
- }
- if (bingo)
- {
- bingo = FALSE;
- for (; holder != '\n' && holder != EOF; holder = getc(init));
- for (;;)
- {
- for (; (holder == ' ' || holder == '\t' || holder == '\n') &&
- holder != EOF; holder = getc(init));
- if (holder == EOF) break;
- if (holder == '#')
- {
- holder = getc(init);
- if (holder == EOF) break;
- if (holder == '#')
- {
- (void) fscanf(init,
- " %s = (%c) %s", name, &inst_type, line);
- for (I = 0; I < M; I++)
- if (strcmp(name, machines[I].name) == 0)
- {
- if (inst_type == 'R' || inst_type == 'L' ||
- inst_type == 'M'|| inst_type == 'N')
- {
- (void) strcpy(machines[I].rmt_directory,
- line);
- machines[I].rmt_install = inst_type;
- switch (inst_type)
- {
- case 'L':
- (void) fscanf(init," ## %s",
- machines[I].lcl_directory);
- break;
- case 'R':
- case 'M':
- (void) sprintf(
- machines[I].lcl_directory,
- "%s/%s", current,
- machines[I].name);
- break;
- case 'N':
- (void) strcpy(
- machines[I].lcl_directory,
- machines[I].rmt_directory);
- break;
- }
- break;
- }
- else
- {
- I = M;
- break;
- }
- }
- if (I == M) break;
- while (fscanf(init,
- " ## %s=(%c) %s", name, &inst_type, line) == 3)
- {
- for (I = 0; I < M; I++)
- if (strcmp(name, machines[I].name) == 0)
- {
- if (inst_type == 'R' || inst_type == 'L' ||
- inst_type == 'M'|| inst_type == 'N')
- {
- (void) strcpy(machines[I].rmt_directory,
- line);
- machines[I].rmt_install = inst_type;
- switch (inst_type)
- {
- case 'L':
- (void) fscanf(init," ## %s",
- machines[I].lcl_directory);
- break;
- case 'R':
- case 'M':
- (void) sprintf(
- machines[I].lcl_directory,
- "%s/%s", current,
- machines[I].name);
- break;
- case 'N':
- (void) strcpy(
- machines[I].lcl_directory,
- machines[I].rmt_directory);
- break;
- }
- break;
- }
- else
- {
- I = M;
- break;
- }
- }
- if (I == M) break;
- }
- if (I != M)
- bingo = TRUE;
- break;
- }
- else
- for (; holder != '\n' && holder != EOF;
- holder = getc(init));
- }
- else
- for (; holder != '\n' && holder != EOF; holder = getc(init));
- }
- }
- (void) fclose(init);
- if (! bingo)
- {
- (void) fprintf(stderr, "%s", messages[5]);
- return(0);
- }
- else
- {
- (void) fprintf(stderr, "%s", messages[6]);
- for(;;)
- {
- (void) fprintf(stderr, " (Y/N) ==> ");
- get_line(enter);
- if (enter[0] != 'Y' && enter[0] != 'y' &&
- enter[0] != 'N' && enter[0] != 'n')
- {
- (void) fprintf(stderr,
- "\n (You should enter either a \"Y\" or a \"N\".)\n\n");
- continue;
- }
- else
- {
- if (enter[0] == 'N' || enter[0] == 'n')
- return(0);
- else
- break;
- }
- }
- }
- (void) fprintf(stderr, "\n\n%s%s%s\n\n", messages[60], arch, messages[61]);
- for(;;)
- {
- (void) fprintf(stderr, " (Y/N) ==> ");
- get_line(enter);
- if (enter[0] != 'Y' && enter[0] != 'y' &&
- enter[0] != 'N' && enter[0] != 'n')
- {
- (void) fprintf(stderr,
- "\n (You should enter either a \"Y\" or a \"N\".)\n\n");
- continue;
- }
- else
- {
- if (enter[0] == 'N' || enter[0] == 'n')
- backend = FALSE;
- break;
- }
- }
-
- }
- else
- {
- /* There was no "dino.init" file, so assume that
- this is a new installation. */
-
- (void) fprintf(stderr, "%s", messages[7]);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(0);
-
- /* For each machine the user decides to define: */
-
- for(M = 0;;)
- {
-
- /* Get the name of the machine. */
-
- (void) fprintf(stderr, "%s%d%s", messages[8], M + 1, messages[9]);
- get_line(enter);
- if (enter[0] =='\0')
- {
- (void) fprintf(stderr,
- "\n If you want to quit the Automated Installer, enter a \"Q\" now;\n");
- (void) fprintf(stderr,
- " if you want to record the existing configurations, enter a \"R\" now;\n");
- (void) fprintf(stderr,
- " otherwise just hit enter to start machine #%d over ==>", M + 1);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(0);
- else
- if (enter[0] =='R' || enter[0] == 'r')
- break;
- else
- continue;
- }
- restart = FALSE;
- for (I = 0; I < M; I++)
- if (strcmp(enter, machines[I].name) == 0)
- {
- (void) fprintf(stderr,
- "\n There is already a machine name %s defined.\n", enter);
- (void) fprintf(stderr,
- " You can not use the same name again.\n\n");
- restart = TRUE;
- break;
- }
- if (restart) continue;
- (void) strcpy(machines[M].name, enter);
-
- machines[M].user[0] = '~';
- machines[M].user[1] = '\0';
-
- /* Get the type of machine. */
-
- for (;;)
- {
- (void) fprintf(stderr, "%s%s%s", messages[10],
- machines[M].name, messages[11]);
- restart = FALSE;
- if (get_line_quit(enter, M+1))
- {
- restart = TRUE;
- break;
- }
- switch (enter[0])
- {
- case 's':
- machines[M].type = enter[0];
- machines[M].rsh = 'F';
- machines[M].directory[0] = '.';
- machines[M].directory[1] = '\0';
- machines[M].address[0] = '.';
- machines[M].address[1] = '\0';
- machines[M].rcp = 'F';
- machines[M].run = 'T';
- machines[M].xmt = TRUE;
- machines[M].home = TRUE;
- machines[M].date = 'T';
- done = TRUE;
- break;
- case 'S':
- machines[M].type = enter[0];
- machines[M].rsh = 'F';
- machines[M].directory[0] = '.';
- machines[M].directory[1] = '\0';
- machines[M].address[0] = '.';
- machines[M].address[1] = '\0';
- machines[M].rcp = 'F';
- machines[M].run = 'T';
- machines[M].xmt = TRUE;
- machines[M].home = TRUE;
- machines[M].date = 'T';
- done = TRUE;
- break;
- case '1':
- machines[M].type = enter[0];
- machines[M].rsh = 'T';
- machines[M].directory[0] = '~';
- machines[M].directory[1] = '\0';
- machines[M].rcp = 'T';
- machines[M].xmt = FALSE;
- machines[M].home = FALSE;
- machines[M].date = 'F';
- done = TRUE;
- break;
- case '2':
- machines[M].type = enter[0];
- machines[M].rsh = 'T';
- machines[M].directory[0] = '~';
- machines[M].directory[1] = '\0';
- machines[M].date = 'T';
- done = TRUE;
- break;
- case '8':
- machines[M].type = enter[0];
- machines[M].rsh = 'T';
- machines[M].directory[0] = '~';
- machines[M].date = 'T';
- machines[M].directory[1] = '\0';
- done = TRUE;
- break;
- case 'G':
- (void) fprintf(stderr,
- "\n Sorry, \"G\" is not implemented at this time. Please try\n");
- (void) fprintf(stderr, " another choice.\n");
- done = FALSE;
- break;
- default:
- (void) fprintf(stderr,
- "\n Sorry, \"%c\" is not one of the allowed choices. Please\n",
- enter[0]);
- (void) fprintf(stderr, " try again.\n");
- done = FALSE;
- break;
- }
- if ( done)
- break;
- }
- if (restart)
- continue;
-
- if (machines[M].type == 's' && ! sim1)
- {
- for (;;)
- {
- restart = FALSE;
- (void) fprintf(stderr, "%siPSC1\n%s", messages[67], messages[68]);
- if (get_line_quit(enter, M+1))
- restart = TRUE;
- else
- {
- if ((cptr1 = strstr(enter, "${ARCHTYPE}")) != NULL ||
- (cptr1 = strstr(enter, "$ARCHTYPE")) != NULL)
- {
- for (cptr2 = &(enter[0]), cptr3 = &(dir[0]);
- cptr2 != cptr1; *(cptr3++) = *(cptr2++));
- for (cptr1 = &(arch[0]); *cptr1 != '\0'; *(cptr3++) = *(cptr1++));
- for (; *cptr2 != '/'; cptr2++);
- for (; *cptr2 != '\0'; *(cptr3++) = *(cptr2++));
- *cptr3 = '\0';
- }
- else
- (void) strcpy(dir, enter);
- if (stat(dir, &buf1) != 0 || ! S_ISREG(buf1.st_mode))
- {
- (void) fprintf(stderr,
- "\n The file: %s\n%s", dir, messages[15]);
- (void) fprintf(stderr, "%d%s", M+1, messages[16]);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(0);
- else
- if (enter[0] =='R' || enter[0] == 'r')
- restart = TRUE;
- }
- else
- {
- (void) strcpy(sim1loc, enter);
- break;
- }
- }
- if (restart)
- break;
- }
- if (restart)
- continue;
- else
- sim1 = TRUE;
- }
-
- if (machines[M].type == 'S' && ! sim2)
- {
- for (;;)
- {
- restart = FALSE;
- (void) fprintf(stderr, "%siPSC2\n%s", messages[67], messages[68]);
- if (get_line_quit(enter, M+1))
- restart = TRUE;
- else
- {
- if ((cptr1 = strstr(enter, "${ARCHTYPE}")) != NULL ||
- (cptr1 = strstr(enter, "$ARCHTYPE")) != NULL)
- {
- for (cptr2 = &(enter[0]), cptr3 = &(dir[0]);
- cptr2 != cptr1; *(cptr3++) = *(cptr2++));
- for (cptr1 = &(arch[0]); *cptr1 != '\0'; *(cptr3++) = *(cptr1++));
- for (; *cptr2 != '/'; cptr2++);
- for (; *cptr2 != '\0'; *(cptr3++) = *(cptr2++));
- *cptr3 = '\0';
- }
- else
- (void) strcpy(dir, enter);
- if (stat(dir, &buf1) != 0 || ! S_ISREG(buf1.st_mode))
- {
- (void) fprintf(stderr,
- "\n The file: %s\n%s", dir, messages[15]);
- (void) fprintf(stderr, "%d%s", M+1, messages[16]);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(0);
- else
- if (enter[0] =='R' || enter[0] == 'r')
- restart = TRUE;
- }
- else
- {
- (void) strcpy(sim2loc, enter);
- break;
- }
- }
- if (restart)
- break;
- }
- if (restart)
- continue;
- else
- sim2 = TRUE;
- }
-
- if (machines[M].rsh == 'T')
- {
- machines[M].rmt_user[0] = '\0';
- (void) fprintf(stderr, "%s%s", messages[18], machines[M].name);
- (void) fprintf(stderr, "%s%s%s", messages[19],
- machines[M].name, messages[20]);
- (void) fprintf(stderr, "%s%s", machines[M].name, messages[21]);
- switch (get_yn(M+1))
- {
- case -1:
- return(0);
- break;
- case 0:
- continue;
- break;
- case 1:
- machines[M].run ='T';
- break;
- case 2:
- machines[M].run ='F';
- machines[M].rsh ='F';
- machines[M].rcp ='F';
- break;
- }
-
- if (machines[M].run == 'T')
- {
- (void) fprintf(stderr,
- "\n\n What is the address of %s%s", machines[M].name, messages[17]);
- if (get_line_quit(enter, M+1))
- continue;
- for (I = 0; I < M; I++)
- if (strcmp(enter, machines[I].address) == 0)
- break;
- if (I < M)
- {
- (void) fprintf(stderr, "%s%s%s%s%s", messages[69],
- machines[M].name, messages[70],
- machines[I].name, messages[71]);
- get_line(enter);
- if (enter[0] == 'Q' || enter[0] == 'q')
- exit(0);
- continue;
- }
- (void) strcpy(machines[M].address, enter);
- if (machines[M].type == '2' || machines[M].type == '8')
- {
- (void) fprintf(stderr, "%s%s%s\n\n",
- messages[22], machines[M].name, messages[74]);
- switch (get_yn(M+1))
- {
- case -1:
- return(0);
- break;
- case 0:
- continue;
- break;
- case 1:
- machines[M].xmt = TRUE;
- machines[M].rcp = 'F';
- machines[M].directory[0] = '.';
- break;
- case 2:
- machines[M].xmt = FALSE;
- machines[M].home = FALSE;
- machines[M].rcp = 'T';
- break;
- }
-
- if (machines[M].xmt)
- {
- (void) fprintf(stderr, "%s%s?\n\n",
- messages[23], machines[M].name);
- switch (get_yn(M+1))
- {
- case -1:
- return(0);
- break;
- case 0:
- continue;
- break;
- case 1:
- machines[M].home = TRUE;
- break;
- case 2:
- machines[M].home = FALSE;
- break;
- }
- }
- }
- }
- else
- (void) strcpy(machines[M].address, "none");
- }
- (void) fprintf(stderr,
- "\n\n What is the largest number of dimensions that %s supports?\n\n",
- machines[M].name);
- for(;;)
- {
- restart = FALSE;
- (void) fprintf(stderr, " ==> ");
- if(get_line_quit(enter, M+1))
- {
- restart = TRUE;
- break;
- }
- if (! isdigit(enter[0]) ||
- (tempi = (int) enter[0] - (int) '0') > 7 ||
- tempi == 0 || enter[1] != '\0')
- {
- (void) fprintf(stderr,
- "\n (You should enter a valid number between 1 and 7.)\n\n");
- continue;
- }
- else
- {
- machines[M].maxdim = machines[M].dim = tempi;
- break;
- }
- }
- if (restart) continue;
-
- if (machines[M].run == 'T')
- {
- if (machines[M].rsh == 'T')
- {
- if (machines[M].xmt)
- {
- (void) fprintf(stderr, "%s %s. Is %s\n%s",
- messages[25], machines[M].name,
- current, messages[26]);
- switch (get_yn(M+1))
- {
- case -1:
- return(0);
- break;
- case 0:
- continue;
- break;
- case 1:
- machines[M].rmt_install = 'L';
- (void) strcpy(machines[M].lcl_directory, current);
- (void) fprintf(stderr, "\n\n%s%s%s%s\n\n%s",
- messages[63], machines[M].name,
- messages[64], machines[M].lcl_directory,
- messages[65]);
- if (get_line_quit(enter, M+1))
- continue;
- (void) strcpy(machines[M].rmt_directory, enter);
- break;
- case 2:
- machines[M].rmt_install = 'R';
- (void) fprintf(stderr, "%s%s%s",
- messages[27], user, messages[28]);
- switch (get_yn(M+1))
- {
- case -1:
- return(0);
- break;
- case 0:
- continue;
- break;
- case 1:
- machines[M].rmt_install = 'L';
- (void) fprintf(stderr, "%s", messages[29]);
- if (get_line_quit(enter, M+1))
- continue;
- (void) strcpy(machines[M].lcl_directory,
- enter);
- (void) fprintf(stderr, "\n\n%s%s%s%s\n\n%s",
- messages[63], machines[M].name,
- messages[64], machines[M].lcl_directory,
- messages[65]);
- if (get_line_quit(enter, M+1))
- continue;
- (void) strcpy(machines[M].rmt_directory,
- enter);
- break;
- case 2:
- break;
- }
- break;
- }
- }
- else
- machines[M].rmt_install = 'R';
- if (machines[M].rmt_install == 'R')
- {
- (void) fprintf(stderr,
- "\n\n What is the full path name of the directory on %s\n%s",
- machines[M].name, messages[30]);
- (void) fprintf(stderr,
- "%s or\n a user that trusts %s on %s%s",
- user, user, machines[M].name, messages[31]);
- if (get_line_quit(enter, M+1))
- continue;
- if (strcmp(enter, "none") == 0)
- {
- machines[M].rmt_install = 'M';
- (void) sprintf(machines[M].lcl_directory, "%s/%s",
- current, machines[M].name);
- (void) fprintf(stderr, "%s%s%s%s%s",
- messages[53], machines[M].name, messages[54],
- machines[M].name, messages[55]);
- if (get_line_quit(enter, M+1))
- continue;
- }
- (void) strcpy(machines[M].rmt_directory, enter);
- }
- if (machines[M].rmt_install == 'R' || machines[M].rmt_install == 'L')
- {
- if (machines[M].rmt_install == 'L')
- (void) strcpy(machines[M].lcl_directory, current);
- else
- (void) sprintf(machines[M].lcl_directory, "%s/%s",
- current, machines[M].name);
- (void) fprintf(stderr, "\n\n Please be patient,\n");
- (void) fprintf(stderr,
- " Checking with the parallel machine %s . . . \n",
- machines[M].name);
- if (pipe(fdes))
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if (fork())
- {
- (void) wait(NULL);
- tempi = read(fdes[0], line, MAXLINESIZE);
- line[tempi] = '\0';
- (void) close(fdes[0]);
- (void) close(fdes[1]);
- }
- else
- {
- (void) dup2(fdes[1], 1);
- (void) dup2(fdes[1], 2);
- (void) execlp("rsh", "rsh", machines[M].address, "pwd", 0);
- }
- choice = 0;
- switch (line[0])
- {
- case 'L':
- if (strncmp(line, "Login incorrect", 15) == 0)
- choice = 3;
- break;
- case 'P':
- if (strncmp(line, "Permission denied", 17) == 0)
- choice = 2;
- break;
- case '/':
- choice = 5;
- break;
- default:
- if ((cptr1 = strchr(line, ':')) != NULL &&
- strncmp(cptr1, ": unknown host", 14) == 0)
- choice = 1;
- break;
- }
- if (choice == 5)
- {
- (void) fprintf(stderr,
- " . . . still checking with %s . . .\n",
- machines[M].name);
- (void) sprintf(dir, "%s/_D_TEST",
- machines[M].rmt_directory);
- if (pipe(fdes))
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if (fork())
- {
- (void) wait(NULL);
- line[0] = '\0';
- (void) fcntl(fdes[0], F_SETFL, O_NDELAY);
- tempi = read(fdes[0], line, MAXLINESIZE);
- line[tempi] = '\0';
- (void) close(fdes[0]);
- (void) close(fdes[1]);
- }
- else
- {
- (void) dup2(fdes[1], 1);
- (void) dup2(fdes[1], 2);
- (void) execlp("rsh", "rsh",
- machines[M].address, "touch", dir, 0);
- }
- if (strlen(line) > 0)
- choice = 4;
- else
- {
- (void) fprintf(stderr,
- " . . . one last check . . .\n");
- if (fork())
- (void) wait(NULL);
- else
- (void) execlp("rsh", "rsh",
- machines[M].address, "rm", dir, 0);
- }
- }
- switch (choice)
- {
- case 0:
- (void) fprintf(stderr,
- " DINO is unable to access %s with \"rsh\" (which\n",
- machines[M].name);
- (void) fprintf(stderr,
- " returned the error --> %s\n", line);
- break;
- case 1:
- (void) fprintf(stderr,
- " The host table on this machine reports that there is no parallel\n");
- (void) fprintf(stderr,
- " machine with the address \"%s\".\n\n",
- machines[M].address);
- break;
- case 2:
- (void) fprintf(stderr,
- " It appears that the permissions in %s's \".rhosts\" file on\n",
- user);
- (void) fprintf(stderr,
- " %s are not set correctly.\n\n", machines[M].name);
- break;
- case 3:
- (void) fprintf(stderr,
- " There appears to be no login for %s on %s.\n\n",
- user, machines[M].name);
- break;
- case 4:
- (void) fprintf(stderr,
- " It appears that %s does not have write permission in\n", user);
- (void) fprintf(stderr,
- " %s on %s\n\n", machines[M].rmt_directory, machines[M].name);
- break;
- case 5:
- break;
- }
- if (choice < 2)
- {
- (void) fprintf(stderr,
- " DINO will not be able to install the back end on %s%s%d over ==> ",
- machines[M].name, messages[32], M+1);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(0);
- if (enter[0] =='M' || enter[0] == 'm')
- machines[M].rmt_install = 'M';
- else
- continue;
- }
- if (choice < 5 && machines[M].rmt_install != 'M')
- {
- (void) fprintf(stderr,
- " Is there another user on %s that trusts %s (i.e. that user's\n",
- machines[M].name, user);
- (void) fprintf(stderr,
- " \".rhosts\" file has %s in it) and that is allowed to write in\n",
- user);
- (void) fprintf(stderr,
- " the directory where you want DINO installed?\n\n");
- switch (get_yn(M+1))
- {
- case -1:
- return(0);
- break;
- case 0:
- continue;
- break;
- case 1:
- (void) fprintf(stderr,
- "\n Please enter the name of that user ==>");
- if (get_line_quit(enter, M+1))
- continue;
- (void) fprintf(stderr,
- "\n Please be patient,\n");
- (void) fprintf(stderr,
- "\n Checking (again) with the parallel machine %s . . . \n",
- machines[M].name);
- if (pipe(fdes))
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if (fork())
- {
- (void) wait(NULL);
- tempi = read(fdes[0], line, MAXLINESIZE);
- line[tempi] = '\0';
- (void) close(fdes[0]);
- (void) close(fdes[1]);
- }
- else
- {
- (void) dup2(fdes[1], 1);
- (void) dup2(fdes[1], 2);
- (void) execlp("rsh", "rsh", machines[M].address,
- "-l", enter, "pwd", 0);
- }
- choice = 0;
- switch (line[0])
- {
- case 'L':
- if (strncmp(line, "Login incorrect", 15)
- == 0)
- choice = 3;
- break;
- case 'P':
- if (strncmp(line, "Permission denied",
- 17) == 0)
- choice = 2;
- break;
- case '/':
- choice = 5;
- break;
- default:
- if ((cptr1 = strchr(line, ':')) != NULL
- && strncmp(cptr1, ": unknown host", 14) == 0)
- choice = 1;
- break;
- }
- if (choice == 5)
- {
- if (pipe(fdes))
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 5; contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if (fork())
- {
- (void) wait(NULL);
- tempi = read(fdes[0], line, MAXLINESIZE);
- line[tempi] = '\0';
- (void) close(fdes[0]);
- (void) close(fdes[1]);
- }
- else
- {
- (void) dup2(fdes[1], 1);
- (void) dup2(fdes[1], 2);
- (void) execlp("rsh", "rsh",
- machines[M].address,
- "-l", enter, "touch", dir, 0);
- }
- if (strlen(line) > 0)
- choice = 4;
- else
- {
- if (fork())
- (void) wait(NULL);
- else
- (void) execlp("rsh", "rsh",
- machines[M].address, "-l",
- enter, "rm", dir, 0);
- }
- }
- switch (choice)
- {
- case 0:
- (void) fprintf(stderr,
- " DINO is unable to access %s with \"rsh\" (which\n",
- machines[M].name);
- (void) fprintf(stderr,
- " returned the error --> %s\n", line);
- break;
- case 1:
- (void) fprintf(stderr,
- " The host table on this machine reports that there is no parallel\n");
- (void) fprintf(stderr,
- " machine with the address \"%s\".\n\n",
- machines[M].address);
- break;
- case 2:
- (void) fprintf(stderr,
- " It appears that the permissions in %s's \".rhosts\" file on\n",
- enter);
- (void) fprintf(stderr,
- " %s are not set correctly.\n\n", machines[M].name);
- break;
- case 3:
- (void) fprintf(stderr,
- " There appears to be no login for %s on %s.\n\n",
- enter, machines[M].name);
- break;
- case 4:
- (void) fprintf(stderr,
- " It appears that %s does not have write permission in\n", enter);
- (void) fprintf(stderr,
- " %s on %s\n\n", machines[M].rmt_directory, machines[M].name);
- break;
- case 5:
- break;
- }
- if (choice < 5)
- {
- (void) fprintf(stderr,
- " DINO will not be able to install the back end on %s%s%d over ==> ",
- machines[M].name, messages[32], M+1);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(0);
- if (enter[0] =='M' || enter[0] == 'm')
- machines[M].rmt_install = 'M';
- else
- continue;
- }
- else
- (void) strcpy(machines[M].rmt_user, enter);
- break;
- case 2:
- (void) fprintf(stderr, "%s%d over again ==>",
- messages[33], M+1);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(0);
- if (enter[0] =='M' || enter[0] == 'm')
- machines[M].rmt_install = 'M';
- else
- continue;
- break;
- }
- }
- (void) fprintf(stderr,
- " . . . %s appears to be set up correctly for installation.\n\n",
- machines[M].name);
- }
- }
- else
- {
- machines[M].rmt_install = 'L';
- (void) strcpy(machines[M].rmt_directory, current);
- (void) sprintf(machines[M].lcl_directory, "%s/%s",
- current, machines[M].name);
- }
- }
- else
- {
- machines[M].rmt_install = 'N';
- (void) strcpy(machines[M].rmt_directory, "Not Installed");
- (void) strcpy(machines[M].lcl_directory, "Not Installed");
- }
-
- (void) fprintf(stderr,
- "\n\n The configuration for %s is:\n\n", machines[M].name);
- (void) fprintf(stderr, " - its type is ");
- switch (machines[M].type)
- {
- case 's':
- (void) fprintf(stderr, "an Intel iPSC1 simulator\n");
- break;
- case 'S':
- (void) fprintf(stderr, "an Intel iPSC2 simulator\n");
- break;
- case '1':
- (void) fprintf(stderr, "an Intel iPSC1\n");
- break;
- case '2':
- (void) fprintf(stderr, "an Intel iPSC2\n");
- break;
- case '8':
- (void) fprintf(stderr,
- "an Intel i860 version of the iPSC2\n");
- break;
- case 'G':
- (void) fprintf(stderr, "a distributed sun machine\n");
- break;
- }
- if (machines[M].address[0] =='.')
- {
- (void) fprintf(stderr,
- " - its address is that it uses the same machine for the\n");
- (void) fprintf(stderr,
- " parallel machine as it does for the compiler\n");
- }
- else
- (void) fprintf(stderr, " - its address is %s\n",
- machines[M].address);
- (void) fprintf(stderr,
- " - its user on the parallel machine will be the same\n");
- (void) fprintf(stderr,
- " as the user on the sun\n");
- if (machines[M].directory[0] == '~')
- {
- (void) fprintf(stderr,
- " - its directory on the parallel machine will be the home\n");
- (void) fprintf(stderr,
- " directory of the user on the sun\n");
- }
- else
- {
- (void) fprintf(stderr,
- " - its directory on the parallel machine will be the same\n");
- (void) fprintf(stderr,
- " as the current directory on the sun\n");
- }
- (void) fprintf(stderr,
- " - it is configured for %d dimensions\n", machines[M].maxdim);
- if (machines[M].run =='T')
- {
- (void) fprintf(stderr,
- " - DINO will automatically run the second \n");
- (void) fprintf(stderr,
- " half of the DINO compilation\n");
- }
- else
- {
- (void) fprintf(stderr,
- " - DINO will stop after the intermediate\n");
- (void) fprintf(stderr,
- " C files are generated\n");
- }
- if (machines[M].run =='T')
- {
- if (machines[M].rsh =='T')
- {
- if (machines[M].rcp =='T')
- (void) fprintf(stderr,
- " - DINO will copy files to %s with \"rcp\"\n", machines[M].name);
- else
- (void) fprintf(stderr,
- " - DINO will not need to copy files to %s\n", machines[M].name);
- if (machines[M].xmt)
- {
- (void) fprintf(stderr,
- " (%s shares its filesystem with the suns,\n");
- if (machines[M].home)
- (void) fprintf(stderr,
- " and the home directories are the same)\n");
- else
- (void) fprintf(stderr,
- " but the home directories are different)\n");
- }
- else
- (void) fprintf(stderr,
- " (%s's filesystem is seperate from the suns)\n");
- (void) fprintf(stderr,
- " - DINO will start the second half of DINO\n");
- (void) fprintf(stderr,
- " on %s with \"rsh\"\n", machines[M].name);
- }
- else
- {
- (void) fprintf(stderr,
- " - DINO will start the second half of DINO\n");
- (void) fprintf(stderr,
- " on the sun with a local call\n");
- }
- }
- if (machines[M].type == 's')
- {
- (void) fprintf(stderr,
- " - The iPSC1 simulator library files can be found at\n");
- (void) fprintf(stderr,
- " %s\n", sim1loc);
- }
- if (machines[M].type == 'S')
- {
- (void) fprintf(stderr,
- " - The iPSC2 simulator library files can be found at\n");
- (void) fprintf(stderr,
- " %s\n", sim2loc);
- }
- switch (machines[M].rmt_install)
- {
- case 'N':
- (void) fprintf(stderr,
- " - DINO will not attempt to install the back end\n");
- break;
- case 'M':
- (void) fprintf(stderr,
- " - DINO will create a local directory named \"%s\"\n",
- machines[M].name);
- (void) fprintf(stderr,
- " in the current directory (%s).\n", current);
- (void) fprintf(stderr,
- " You will have to move the contents of that directory to the\n");
- (void) fprintf(stderr,
- " directory \"%s\" on %s\n",
- machines[M].rmt_directory, machines[M].name);
- (void) fprintf(stderr,
- " and finish the installation there.\n");
- break;
- case 'L':
- (void) fprintf(stderr,
- " - DINO will attempt to install the back end for %s in\n",
- machines[M].name);
- (void) fprintf(stderr,
- " the directory %s\n", machines[M].lcl_directory);
- if (machines[M].rsh == 'T')
- {
- (void) fprintf(stderr,
- " (because the directory is cross-mounted to %s\n",
- machines[M].name);
- (void) fprintf(stderr,
- " where its path is %s).\n", machines[M].rmt_directory);
- }
- else
- (void) fprintf(stderr,
- " (because %s is on this machine).\n", machines[M].name);
- break;
- case 'R':
- (void) fprintf(stderr,
- " - DINO will attempt to install the back end directly on %s\n",
- machines[M].name);
- (void) fprintf(stderr,
- " in the directory %s\n", machines[M].rmt_directory);
- break;
- }
-
-
- (void) fprintf(stderr, "\n Record this configuration?\n\n");
- for(;;)
- {
- (void) fprintf(stderr, " (Y/N) ==> ");
- get_line(enter);
- if (enter[0] != 'Y' && enter[0] != 'y' &&
- enter[0] != 'N' && enter[0] != 'n')
- {
- (void) fprintf(stderr,
- "\n (You should enter either a \"Y\" or a \"N\".)\n\n");
- continue;
- }
- else
- {
- if (enter[0] == 'Y' || enter[0] == 'y')
- M++;
- break;
- }
- }
-
- done = TRUE;
- if (M < (MAXMACHINES))
- {
- (void) fprintf(stderr,
- "\n\n Configure another parallel machine?\n\n");
- for(;;)
- {
- (void) fprintf(stderr, " (Y/N) ==> ");
- get_line(enter);
- if (enter[0] != 'Y' && enter[0] != 'y' &&
- enter[0] != 'N' && enter[0] != 'n')
- {
- (void) fprintf(stderr,
- "\n (You should enter either a \"Y\" or a \"N\".)\n\n");
- continue;
- }
- else
- {
- if (enter[0] == 'Y' || enter[0] == 'y')
- done = FALSE;
- break;
- }
- }
- }
- else
- (void) fprintf(stderr,
- "\n\n You have defined the largest number of parallel machines allowed.\n");
- if (done) break;
- }
- if (M == 0)
- {
- (void) fprintf(stderr,
- "\n You have not defined any parallel machines.\n Bye bye.\n");
- return(0);
- }
- (void) fprintf(stderr,
- "\n\n The following parallel machines have been defined:\n");
- for (I=0; I < M; I++)
- (void) fprintf(stderr," %s\n", machines[I].name);
- if (M > 1)
- {
- (void) fprintf(stderr, "%s", messages[24]);
- for(;;)
- {
- (void) fprintf(stderr, " Enter a machine name ==> ");
- get_line(enter);
- for (I = 0; I < M; I++)
- if (strcmp(enter, machines[I].name) == 0)
- {
- dfalt = I;
- break;
- }
- if (I < M)
- break;
- (void) fprintf(stderr,
- "\n You have not entered a valid machine name.\n\n");
- }
- }
- (void) fprintf(stderr,
- "\n\n Proceed with the installation of %s?\n\n",
- (M>1)?"these machines":"this machine");
- for(;;)
- {
- (void) fprintf(stderr, " (Y/N) ==> ");
- get_line(enter);
- if (enter[0] != 'Y' && enter[0] != 'y' &&
- enter[0] != 'N' && enter[0] != 'n')
- {
- (void) fprintf(stderr,
- "\n (You should enter either a \"Y\" or a \"N\".)\n\n");
- continue;
- }
- else
- {
- if (enter[0] == 'N' || enter[0] == 'n')
- return(0);
- else
- break;
- }
- }
- }
-
- /* OK, we are done asking questions. Now install the machines
- that have been defined in the first half of the program. */
-
- /* First, make sure that the general directory structure
- for the front end is correct and the various
- shell files and examples are installed: */
-
- (void) fprintf(stderr, "\n\n Checking directory structure . . .\n");
- maked("bin", (char *) NULL, (char *) NULL);
- maked(arch, "bin", (char *) NULL);
- maked("bin/local", (char *) NULL, (char *) NULL);
- copy("source/shell", "dino.special.example", "bin/local", 0);
- copy("source/shell", "dino.init.example", "bin/local", 0);
- (void) sprintf(dir, "bin/%s", arch);
- copy("source/shell", "dino", dir, 0);
- maked("lib", (char *) NULL, (char *) NULL);
- maked(arch, "lib", (char *) NULL);
- (void) fprintf(stderr, "\n Directory structure correct\n");
-
- /* If this is an initial installation,
- create the "dino.init" file. */
-
- if (! update)
- {
- (void) fprintf(stderr,
- "\n Writing a new configuration file (dino.init). . .\n");
- if ((init = fopen("bin/local/dino.init", "w")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\n\t\tError opening %s\n", "bin/local/dino.init");
- perror("\t\t\t");
- (void) fprintf(stderr,
- "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
-
- if ((input = fopen("source/install/DI1", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "DI1");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, init);
- (void) fclose(input);
-
- (void) fprintf(init, "Dhome=%s\n", current);
-
- if ((input = fopen("source/install/DI2", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "DI2");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, init);
- (void) fclose(input);
-
- (void) fprintf(init, "Dmachs=\"%s %s %s %s %c%d%c%c%c%c%d",
- machines[0].name, machines[0].address,
- machines[0].user, machines[0].directory,
- machines[0].type, machines[0].maxdim,
- machines[0].rcp, machines[0].rsh,
- machines[0].run, machines[0].date,
- machines[0].dim);
- for (I = 1; I < M; I++)
- (void) fprintf(init, " \\\n %s %s %s %s %c%d%c%c%c%c%d",
- machines[I].name, machines[I].address,
- machines[I].user, machines[I].directory,
- machines[I].type, machines[I].maxdim,
- machines[I].rcp, machines[I].rsh,
- machines[I].run, machines[I].date,
- machines[I].dim);
- (void) fprintf(init, "\"\n");
-
- if ((input = fopen("source/install/DI3", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "DI3");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, init);
- (void) fclose(input);
-
- for (I = 0; I < M; I++)
- {
- (void) fprintf(init, "## %s = (%c) %s\n", machines[I].name,
- machines[I].rmt_install, machines[I].rmt_directory);
- if (machines[I].rmt_install == 'L')
- (void) fprintf(init, "## %s\n",
- machines[I].lcl_directory);
- }
-
- if ((input = fopen("source/install/DI4", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "DI4");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, init);
- (void) fclose(input);
-
-
- (void) fprintf(init, "sDmachine=%s\n", machines[dfalt].name);
-
- if ((input = fopen("source/install/DI5", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "DI5");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, init);
- (void) fclose(input);
-
- (void) fprintf(init, "export Dhome Dmachs sDmachine\n");
-
- (void) fclose(init);
-
- (void) fprintf(stderr,
- " Configuration file (dino.init) written.\n");
- }
-
- /* Create the link to dino.init. We have to do this all the
- time because if we are doing a sun3/sun4 installation,
- we need two links, even though the second installation
- is treated as an update. */
-
- (void) sprintf(name, "%s/bin/local/dino.init", current);
- (void) sprintf(name2, "%s/bin/%s/dino.init", current, arch);
- (void) unlink(name2);
- if (symlink(name, name2) != 0)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 10: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
-
- /* If we are supposed to, generate the core of the DINO compiler. */
-
- if (source)
- {
- (void) fprintf(stderr,
- " Generating the main portion of the DINO compiler\n");
- (void) fprintf(stderr,
- " (please be patient, this is a lengthy process) . . .\n\n");
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n Make failed for the main portion of the DINO compiler.\n\n");
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- (void) sprintf(name, "ARCHTYPE=%s", arch);
- (void) chdir("source/compiler");
- (void) execlp("make", "make", name, 0);
- }
- }
-
- /* Generate the user shell for the front end of the DINO compiler. */
-
- (void) fprintf(stderr,
- "\n Generating the user shell for the DINO compiler . . .\n\n");
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n Make failed for the user shell for the DINO compiler.\n");
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- (void) sprintf(name, "ARCHTYPE=%s", arch);
- (void) chdir("source/shell");
- (void) execlp("make", "make", name, 0);
- }
-
- /* Find out if we have any backends that run on this machine.
- If so, set an appropriate flag for those kinds that do. */
-
- sim1 = sim2 = grail = FALSE;
- for (I = 0; I < M; I++)
- {
- if (machines[I].rsh != 'T')
- {
- switch (machines[I].type)
- {
- case 's':
- sim1 = TRUE;
- break;
- case 'S':
- sim2 = TRUE;
- break;
- case 'G':
- grail = TRUE;
- break;
- }
- }
- }
-
- /* If there is a local backend, install the "dino2" file. If
- this is an initial installation, generate the "dino2.init" file. */
-
- if (sim1 || sim2 || grail)
- {
- (void) fprintf(stderr,
- "\n\n Generating a local back end for the DINO compiler . . .\n\n");
- (void) sprintf(dir, "bin/%s", arch);
- copy("source/shell2", "dino2", dir, 0);
- if (! update || newarch)
- {
- for (I = 0; I < M; I++)
- if (machines[I].type == 's' ||
- machines[I].type == 'S' || machines[I].type == 'G')
- {
- (void) strcpy(name, machines[I].name);
- break;
- }
- (void) fprintf(stderr,
- "\n\n Writing a new configuration file (dino2.init). . .\n");
- (void) sprintf(name2, "bin/%s/dino2.init", arch);
- if ((output = fopen(name2, "w")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\n\t\tError opening %s\n", name2);
- perror("\t\t\t");
- (void) fprintf(stderr,
- "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
-
- if ((input = fopen("source/install/D2I1", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D2I1");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, "Dhome=%s\n", current);
-
- if ((input = fopen("source/install/D2I2", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D2I2");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, "Destination=%s\n", name);
-
- if ((input = fopen("source/install/D2I3", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D2I3");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, "Suffix=%s\n", name);
-
- (void) fclose(output);
- (void) fprintf(stderr,
- " Configuration file (dino2.init) written.\n\n");
- }
- }
-
- /* For each machine that runs on this machine (local
- parallel machine), create a machine specific
- configuration file. The general type of these
- files are different for the iPSC1 simulator, the
- iPSC2 simulator, and Grail. */
-
- for (I = 0; I < M; I++)
- {
- if (machines[I].rsh != 'T' && !update)
- {
- switch (machines[I].type)
- {
- case 's':
- (void) sprintf(name, "bin/local/new.%s", machines[I].name);
- (void) fprintf(stderr,
- "\n\n Writing a new configuration file (dino2.%s). . .\n",
- machines[I].name);
- if ((output = fopen(name, "w")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\n\t\tError opening %s\n", name);
- perror("\t\t\t");
- (void) fprintf(stderr,
- "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
-
- if ((input = fopen("source/install/D1S1", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D1S1");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, " %s \\\n",
- sim1loc);
-
- if ((input = fopen("source/install/D1S2", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D1S2");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, " %s \\\n",
- sim1loc);
-
- if ((input = fopen("source/install/DS3", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "DS3");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fclose(output);
- (void) fprintf(stderr,
- " Configuration file (dino.%s) written.\n\n",
- machines[I].name);
- break;
- case 'S':
- (void) sprintf(name, "bin/local/new.%s", machines[I].name);
- (void) fprintf(stderr,
- "\n\n Writing a new configuration file (dino2.%s). . .\n",
- machines[I].name);
- if ((output = fopen(name, "w")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\n\t\tError opening %s\n", name);
- perror("\t\t\t");
- (void) fprintf(stderr,
- "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
-
- if ((input = fopen("source/install/D2S1", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D2S1");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, " %s \\\n",
- sim2loc);
-
- if ((input = fopen("source/install/D2S2", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D2S2");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, " %s \\\n",
- sim2loc);
-
- if ((input = fopen("source/install/DS3", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "DS3");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fclose(output);
- (void) fprintf(stderr,
- " Configuration file (dino.%s) written.\n\n",
- machines[I].name);
- break;
- case 'G':
- break;
- }
- }
- }
-
- /* If there is an iPSC1 simulator installed here, install the
- appropriate example, and create the necessary backend library. */
-
- if (sim1)
- {
- (void) fprintf(stderr,
- "\n\n Setting up the local files for an iPSC1 simulator . . .\n\n");
- copy("source/shell2", "dino2.simulator1.example", "bin/local", 0);
- (void) sprintf(name, "ARCHTYPE=%s", arch);
- (void) fprintf(stderr,
- "\n\n Generating the DINO library for an iPSC1 simulator . . .\n\n");
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n Make failed for the back end for %s.\n", line);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- (void) chdir("source/library");
- (void) execlp("make", "make", name, "sim1", 0);
- }
- }
-
- /* If there is an iPSC2 simulator installed here, install the
- appropriate example, and create the necessary backend library. */
-
-
- if (sim2)
- {
- (void) fprintf(stderr,
- "\n\n Setting up the local files for an iPSC2 simulator . . .\n\n");
- copy("source/shell2", "dino2.simulator2.example", "bin/local", 0);
- (void) sprintf(name, "ARCHTYPE=%s", arch);
- (void) fprintf(stderr,
- "\n\n Generating the DINO library for an iPSC2 simulator . . .\n\n");
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n Make failed for the back end for %s.\n", line);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- (void) chdir("source/library");
- (void) execlp("make", "make", name, "sim2", 0);
- }
- }
-
- /* If Grail is installed here, install the
- appropriate example, and create the necessary backend library. */
-
- if (grail)
- {
- }
-
- /* If there are any back end machines on this machine (local
- parallel machine), make the backend shell (that means,
- compile the various programs "dino2" uses, rename the
- "new" files as appropriate, and create any necessary links). */
-
- if (sim1 || sim2 || grail)
- {
- (void) fprintf(stderr,
- "\n Doing the last part of the DINO backend . . .\n\n");
- (void) sprintf(name, "ARCHTYPE=%s", arch);
- if (! update)
- {
- for (I = 0; machines[I].type != 's' &&
- machines[I].type != 'S' && machines[I].type != 'G'; I++);
- (void) sprintf(name2, "DEST=%s", machines[I].name);
- for (I++; I < M; I++)
- if (machines[I].type == 's' ||
- machines[I].type == 'S' || machines[I].type == 'G')
- {
- (void) strcat(name2, " ");
- (void) strcat(name2, machines[I].name);
- }
- }
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n Make failed for the back end for %s.\n", name);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- (void) chdir("source/shell2");
- if (update)
- {
- if (newarch)
- (void) execlp("make", "make", name, "INIT=YES", "all", 0);
- else
- (void) execlp("make", "make", name, "all", 0);
- }
- else
- (void) execlp("make", "make", name, "INIT=YES", name2, "all", 0);
- }
- (void) fprintf(stderr,
- "\n DINO backend for local machines finished.\n\n");
- }
-
- /* Now, for each remote parallel machine that we
- want installed, put in the whole backend. */
-
- if (backend)
- for (I = 0; I < M; I++)
- {
- machines[I].install = FALSE;
- if (machines[I].rsh == 'T' && machines[I].rmt_install != 'N')
- {
- machines[I].install = TRUE;
- for (J = 0; J < I; J++)
- if (strcmp(machines[I].address, machines[J].address) == 0)
- {
- machines[I].install = FALSE;
- break;
- }
- }
- }
-
- for (I = 0; I < M; I++)
- {
- if (machines[I].install && backend)
- {
- (void) fprintf(stderr,
- "\n Generating the back end for %s . . .\n\n", machines[I].name);
- switch (machines[I].type)
- {
- case '1':
- (void) strcpy(target, "iPSC1");
- break;
- case '2':
- (void) strcpy(target, "iPSC2");
- break;
- case '8':
- (void) strcpy(target, "i860");
- break;
- }
- (void) fprintf(stderr,
- " Creating a local copy of the directories\n");
- (void) fprintf(stderr,
- " and files needed for %s . . .\n",
- machines[I].name);
- if (machines[I].rmt_install == 'R' || machines[I].rmt_install == 'M')
- {
- maked(machines[I].name, (char *) NULL, current);
- (void) sprintf(targetd, "%s/%s", current, machines[I].name);
- }
- else
- (void) strcpy(targetd, machines[I].lcl_directory);
- if (machines[I].rmt_install == 'M')
- {
- (void) fprintf(stderr,
- "\n Writing a manual Makefile . . .\n");
- (void) sprintf(name, "%s/Makefile", targetd);
- if ((output = fopen(name, "w")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\n\t\tError opening %s\n", name);
- perror("\t\t\t");
- (void) fprintf(stderr,
- "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
- if (update)
- (void) strcpy(name2, "all");
- else
- (void) sprintf(name2, "INIT=YES DEST=%s all", machines[I].name);
- (void) fprintf(output, "all\t:\n");
- (void) fprintf(output, "\t@cd source/library; make %s\n", target);
- (void) fprintf(output, "\t@cd source/shell2; make ARCHTYPE=%s %s\n", target, name2);
- (void) fclose(output);
- (void) fprintf(stderr,
- " Manual Makefile done.\n");
- }
-
- maked("bin", (char *) NULL, targetd);
-
- maked("local", "bin", targetd);
- (void) sprintf(name, "dino2.%s.example", target);
- (void) sprintf(sourced, "%s/source/shell2", current);
- (void) sprintf(dir, "%s/bin/local", targetd);
- copy(sourced, name, "dino2.init.example", dir, 0);
- if (! update)
- {
- (void) sprintf(name2, "%s/new.%s", dir, machines[I].name);
- copy(sourced, name, name2, 0);
- }
-
- maked(target, "bin", targetd);
- (void) sprintf(dir, "%s/bin/%s", targetd, target);
- copy(sourced, "dino2", dir, 0);
- if (! update)
- {
- (void) fprintf(stderr,
- "\n Writing a new configuration file (dino2.init). . .\n");
- (void)sprintf(name, "%s/bin/%s/new.init", targetd, target);
- if ((output = fopen(name, "w")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\n\t\tError opening %s\n", name);
- perror("\t\t\t");
- (void) fprintf(stderr,
- "FATAL SYSTEM ERROR 6: Contact dino@cs.colorado.edu for help\n\n");
- exit(1);
- }
-
- if ((input = fopen("source/install/D2I1", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D2I1");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, "Dhome=%s\n", machines[I].rmt_directory);
-
- if ((input = fopen("source/install/D2I2", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D2I2");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, "Destination=%s\n", machines[I].name);
-
- if ((input = fopen("source/install/D2I3", "r")) == NULL)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 7 (%s): Contact dino@cs.colorado.edu for help\n\n",
- "D2I3");
- exit(1);
- }
- while (! feof(input))
- if (fgets(line, MAXLINESIZE, input) != NULL)
- (void) fputs(line, output);
- (void) fclose(input);
-
- (void) fprintf(output, "Suffix=%s\n", machines[I].name);
-
- (void) fclose(output);
-
- (void) fprintf(stderr,
- " Configuration file (dino2.init) written.\n");
- }
-
- maked("lib", (char *) NULL, targetd);
-
- maked(target, "lib", targetd);
-
- maked("source", (char *) NULL, targetd);
-
- maked("shell2", "source", targetd);
- (void) sprintf(dir, "%s/source/shell2", targetd);
- copy(sourced, "Makefile", "Makescript", "dinocrdr", "newer2.c",
- "rootextr.c", "returndir.c", dir, 0);
-
- maked("inc", "source", targetd);
- (void) sprintf(dir, "%s/source/inc", targetd);
- (void) sprintf(sourced, "%s/source/inc", current);
- copy(sourced, "*", dir, 0);
-
- maked("library", "source", targetd);
- (void) sprintf(dir, "%s/source/library", targetd);
- (void) sprintf(sourced, "%s/source/library", current);
- copy(sourced, "D_bitmaps.c", "D_lib.c", "D_reduct.c",
- "hostinit.c", "internal.c", "node_main.c",
- "quick.c", "route.c", "stub.c", "timer.c", dir, 0);
- if (machines[I].type == '1')
- {
- copy(sourced, "copy.obj", dir, 0);
- (void) strcat(dir, "/Makefile");
- copy(sourced, "Makefile.iPSC1", dir, 0);
- }
- else
- copy(sourced, "copy2.s", "Makefile", dir, 0);
-
- switch (machines[I].rmt_install)
- {
- case 'R':
- (void) fprintf(stderr,
- " \n Copying the directories and files to %s . . .\n",
- machines[I].name);
- if (machines[I].rmt_user[0] != '\0')
- (void) sprintf(name, "%s@%s:%s",
- machines[I].rmt_user,
- machines[I].address,
- machines[I].rmt_directory);
- else
- (void) sprintf(name, "%s:%s", machines[I].address,
- machines[I].rmt_directory);
-
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n \"rcp\" failed for the back end for %s.\n",
- machines[I].name);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- if (machines[I].type == '1')
- (void) strcpy(name2, "-r");
- else
- (void) strcpy(name2, "-pr");
- (void) chdir(machines[I].name);
- (void) execlp("rcp", "rcp", name2, "bin",
- "lib", "source", name, 0);
- }
-
- (void) fprintf(stderr,
- "\n Deleting the local copy of the directories and files . . .\n");
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n \"rm -rf\" failed for the back end for %s.\n",
- machines[I].name);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- (void) execlp("rm", "rm", "-rf", machines[I].name, 0);
- }
-
- (void) fprintf(stderr,
- "\n Making the back end on %s:\n\n", machines[I].name);
- (void) fprintf(stderr, " libraries first . . .\n\n");
-
- (void) sprintf(name, "%s/source/library",
- machines[I].rmt_directory);
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n \"rsh make library\" failed for the back end for %s.\n",
- machines[I].name);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- if (machines[I].rmt_user[0] != '\0')
- (void) execlp("rsh", "rsh", "-l",
- machines[I].rmt_user,
- machines[I].address,
- "cd", name, ";", "make", target, 0);
- else
- (void) execlp("rsh", "rsh", machines[I].address, "cd",
- name, ";", "make", target, 0);
- }
-
- (void) fprintf(stderr,
- "\n then the back-end shell . . .\n\n");
-
- (void) sprintf(dir, "%s/source/shell2", machines[I].rmt_directory);
- (void) sprintf(name, "ARCHTYPE=%s", target);
- (void) sprintf(name2, "DEST=%s", machines[I].name);
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n \"rsh make shell2\" failed for the back end for %s.\n",
- machines[I].name);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- if (machines[I].rmt_user[0] != '\0')
- {
- if (update)
- (void) execlp("rsh", "rsh", "-l",
- machines[I].rmt_user,
- machines[I].address,
- "cd", dir, ";", "make", name, "INIT=YES", name2, "all", 0);
- else
- (void) execlp("rsh", "rsh", "-l",
- machines[I].rmt_user,
- machines[I].address,
- "cd", dir, ";", "make", name, "all", 0);
- }
- else
- {
- if (update)
- (void) execlp("rsh", "rsh",
- machines[I].address, "cd",
- dir, ";", "make", name, "all", 0);
- else
- (void) execlp("rsh", "rsh",
- machines[I].address, "cd",
- dir, ";", "make", name, "INIT=YES", name2, "all", 0);
- /* (void) fprintf(stderr, "%s %s %s %s %s %s %s %s %s %s %s\n\n", "rsh", "rsh",
- machines[I].address, "cd",
- dir, ";", "make", name, "INIT=YES", name2, "all", 0); */
- }
- }
- break;
- case 'L':
- (void) fprintf(stderr,
- " \n Making the back end on %s:\n\n",
- machines[I].name);
- (void) fprintf(stderr,
- " the back-end shell first . . .\n\n");
-
- (void) sprintf(dir,
- "%s/source/shell2", machines[I].rmt_directory);
- (void) sprintf(name, "ARCHTYPE=%s", target);
- (void) sprintf(name2, "DEST=%s", machines[I].name);
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n \"rsh make shell2\" failed for the back end for %s.\n",
- machines[I].name);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- if (machines[I].rmt_user[0] != '\0')
- {
- if (update)
- (void) execlp("rsh", "rsh", "-l",
- machines[I].rmt_user,
- machines[I].address,
- "cd", dir, ";", "make", name, "all", 0);
- else
- (void) execlp("rsh", "rsh", "-l",
- machines[I].rmt_user,
- machines[I].address,
- "cd", dir, ";", "make",
- name, "INIT=YES", name2, "all", 0);
- }
- else
- {
- if (update)
- (void) execlp("rsh", "rsh",
- machines[I].address, "cd",
- dir, ";", "make", name, "all", 0);
- else
- (void) execlp("rsh", "rsh",
- machines[I].address, "cd",
- dir, ";", "make", name,
- "INIT=YES", name2, "all", 0);
- }
- }
-
- (void) fprintf(stderr,
- "\n then the libraries . . .\n\n");
-
- (void) sprintf(name, "%s/source/library", machines[I].rmt_directory);
- if (fork())
- {
- (void) wait(&status);
- if (status)
- {
- (void) fprintf(stderr,
- "\n\n \"rsh make library\" failed for the back end for %s.\n",
- machines[I].name);
- (void) fprintf(stderr,
- " Contact dino@cs.colorado.edu for help.\n\n");
- return(0);
- }
- }
- else
- {
- if (machines[I].rmt_user[0] != '\0')
- (void) execlp("rsh", "rsh", "-l",
- machines[I].rmt_user,
- machines[I].address, "cd",
- name, ";", "make", target, 0);
- else
- (void) execlp("rsh", "rsh", machines[I].address,
- "cd", name, ";", "make", target, 0);
- }
- break;
- }
- (void) fprintf(stderr,
- "\n Back end for %s is finished.\n\n", machines[I].name);
-
- }
- }
-
- (void) fprintf(stderr, " (Hit return to continue)");
- get_line(enter);
-
- if (update)
- {
- if (backend)
- {
- (void) fprintf(stderr, "\n\n\n\n\n\n\n\n%s", messages[56]);
- for (I = 0; I < M; I++)
- (void) fprintf(stderr, " %s\n", machines[I].name);
- bingo = FALSE;
- for (I = 0; I < M; I++)
- if (machines[I].rmt_install == 'M')
- {
- bingo = TRUE;
- (void) fprintf(stderr, "\n (Hit return to continue)");
- get_line(enter);
- (void) fprintf(stderr, "%s%s%s%s/%s\n\n%s%s\n\n%s%s%s%s\n\n%s",
- messages[57], machines[I].name, messages[58],
- current, machines[I].name, messages[41],
- machines[I].rmt_directory, messages[42],
- machines[I].name, messages[43],
- machines[I].rmt_directory, messages[44]);
- }
- if (bingo)
- {
- (void) fprintf(stderr, "\n (Hit return to continue)");
- get_line(enter);
- }
- }
- else
- (void) fprintf(stderr, "\n\n\n\n\n\n\n\n%s", messages[62]);
- (void) fprintf(stderr, "%s", messages[59]);
- }
- else
- {
- (void) fprintf(stderr, "\n\n\n\n\n\n\n\n%s%s%s%s%s",
- messages[34], current, messages[35], current, messages[36]);
- get_line(enter);
- (void) fprintf(stderr,
- "\n\n DINO has defined %d parallel machine%s:\n\n",
- M, M>1?"s":"");
- for (I = 0; I < M; I++)
- {
- (void) fprintf(stderr, " %s:\n", machines[I].name);
- if (machines[I].rsh == 'T')
- {
- switch (machines[I].type)
- {
- case '1':
- (void) strcpy(target, "iPSC1");
- break;
- case '2':
- (void) strcpy(target, "iPSC2");
- break;
- case '8':
- (void) strcpy(target, "i860");
- break;
- }
- (void) fprintf(stderr, "%s%s%s%s%s", messages[37], target,
- messages[38], machines[I].rmt_directory, messages[39]);
- if (machines[I].rmt_install == 'M')
- {
- (void) fprintf(stderr, "%s%s/%s\n\n%s%s\n\n%s%s%s%s\n\n%s",
- messages[40], current, machines[I].name,
- messages[41], machines[I].rmt_directory,
- messages[42], machines[I].name, messages[43],
- machines[I].rmt_directory, messages[44]);
- }
- (void) fprintf(stderr, "%s", messages[45]);
- get_line(enter);
- (void) fprintf(stderr, "\n\n");
- }
- else
- {
- if (machines[I].run == 'F')
- {
- (void) fprintf(stderr, "%s", messages[46]);
- get_line(enter);
- (void) fprintf(stderr, "\n\n");
- }
- else
- {
- (void) fprintf(stderr, "%s", messages[47]);
- get_line(enter);
- (void) fprintf(stderr, "\n\n");
- }
- }
- }
- bingo = FALSE;
- for (I = 0; I < M; I++)
- if (machines[I].rsh == 'T')
- {
- bingo = TRUE;
- break;
- }
-
- if (bingo)
- {
- (void) fprintf(stderr, "%s", messages[48]);
- get_line(enter);
- (void) fprintf(stderr, "\n\n");
- }
-
- if (strcmp(arch, "sun4") == 0)
- (void) strcpy(target, "sun3");
- else
- (void) strcpy(target, "sun4");
-
- (void) fprintf(stderr, "%s%s%s%s%s", messages[49], arch,
- messages[50], target, messages[51]);
- get_line(enter);
- (void) fprintf(stderr, "\n\n");
- (void) fprintf(stderr, "%s", messages[52]);
- }
-
- return(0);
- }
-
-
- /*********************************************************************
- *
- * This function is used to get a yes/no answer. It returns:
- *
- * -1 if the user wants to quit the automated installer
- * 0 if the user wants to start this machine over
- * 1 if the answer is yes
- * 2 if the answer is no
- *
- * The parameter is the current machine number.
- *
- ********************************************************************/
-
- static int get_yn(number)
- int number;
- {
- char enter[MAXLINESIZE];
-
- for(;;)
- {
- (void) fprintf(stderr, " (Y/N) ==> ");
- get_line(enter);
- if (enter[0] == '\0')
- {
- (void) fprintf(stderr, "%s%d%s", messages[12], number, messages[13]);
- get_line(enter);
- if (enter[0] =='Q' || enter[0] == 'q')
- return(-1);
- if (enter[0] =='\0')
- return(0);
- }
- if (enter[0] != 'Y' && enter[0] != 'y' &&
- enter[0] != 'N' && enter[0] != 'n')
- {
- (void) fprintf(stderr, "%s", messages[14]);
- continue;
- }
- else
- {
- if (enter[0] == 'Y' || enter[0] == 'y')
- return(1);
- else
- return(2);
- }
- }
- }
-
- /********************************************************************
- *
- * Gets a line from stdio. Takes a pointer to an existing string,
- * turns the line into a string.
- *
- ********************************************************************/
-
- static void get_line(str)
- char *str;
- {
- int I = 0;
-
- do
- str[I++] = getchar();
- while ((str[I - 1] != '\n') && (I < MAXLINESIZE - 1));
- str[I - 1] = '\0';
- }
-
-
- /********************************************************************
- *
- * Gets a line from stdio. If the line is empty, asks if the
- * user wants to quit or start this machine over. Takes a
- * pointer to an existing string, turns the line into a
- * string. Also takes the number of the machine being
- * defined.
- *
- ********************************************************************/
-
- static int get_line_quit(str, number)
- char *str;
- int number;
- {
- get_line(str);
- if (str[0] =='\0')
- {
- (void) fprintf(stderr,
- "\n If you want to quit the Automated Installer, enter a \"Q\" now;\n");
- (void) fprintf(stderr,
- " otherwise just hit return to start machine #%d over ==>", number);
- get_line(str);
- if (str[0] =='Q' || str[0] == 'q')
- exit(0);
- else
- return(1);
- }
- return(0);
- }
-
-
- /********************************************************************
- *
- * Copies one or more files. The parameters are the source
- * directory, one or more files, (optionally) a target
- * directory, and a NULL pointer. The source directory
- * can be NULL, in which case, it is assumed to be the
- * current directory. If the last (non NULL) parameter
- * is not a directory, there can only be two files, the
- * first being copied to the second (i.e., allows you to
- * rename the file being copied). If the second parameter
- * is a "*", all files in the source directory are copied
- * and there must be a target directory. Permissions are
- * maintained. Exits with an error message if it fails.
- *
- ********************************************************************/
-
- static void copy(va_alist)
- va_dcl
- {
- va_list parm;
- int count;
- int I;
- int size;
- BOOL all = FALSE;
- BOOL single = FALSE;
- BOOL docopy;
- char *source, *target, *file;
- char input[MAXPATHLEN], output[MAXPATHLEN];
- char buffer[BUFSIZE];
- int fdin, fdout;
- DIR *dirp;
- struct dirent *entry;
- struct stat buf1, buf2;
- struct utimbuf ftime;
- char *name;
-
- va_start(parm);
- source = va_arg(parm, char *);
- file = va_arg(parm, char *);
- if (file[0] == '*')
- {
- all = TRUE;
- target = va_arg(parm, char *);
- if (stat(target, &buf1) != 0 || ! S_ISDIR(buf1.st_mode))
- copyerr();
- }
- else
- {
- for(count = 0; file != NULL;
- count++, target = file, file = va_arg(parm, char *));
- count--;
- if ((single = (stat(target, &buf1) != 0 || S_ISREG(buf1.st_mode))) &&
- count != 1)
- copyerr();
- }
- va_end(parm);
-
-
- if (all)
- {
- if ((dirp = opendir(source)) == NULL)
- copyerr(1, source);
- while((entry = readdir(dirp)) != NULL)
- {
- if (source != NULL)
- (void) sprintf(input, "%s/%s", source, entry->d_name);
- else
- (void) strcpy(input, entry->d_name);
- if (stat(input, &buf1) == 0)
- {
- if (S_ISREG(buf1.st_mode))
- {
- (void) sprintf(output, "%s/%s", target, entry->d_name);
- docopy = FALSE;
- if (stat(output, &buf2) == 0)
- {
- if (buf1.st_mtime > buf2.st_mtime)
- docopy = TRUE;
- }
- else
- if (errno == ENOENT)
- docopy = TRUE;
- else
- copyerr(3, entry->d_name);
- if (docopy)
- {
- if ((fdin = open(input, O_RDONLY)) < 0)
- copyerr(2, entry->d_name);
- if ((fdout = open(output,
- O_CREAT | O_WRONLY | O_TRUNC, buf1.st_mode)) < 0)
- copyerr(3, entry->d_name);
- while ((size = read(fdin, buffer, BUFSIZE)) > 0)
- if (write(fdout, buffer, size) != size)
- copyerr(4, entry->d_name);
- if (size < 0)
- copyerr(5, entry->d_name);
- (void) fprintf(stderr,
- " Copying %s . . .\n", entry->d_name);
- (void) close(fdin);
- (void) close(fdout);
- ftime.actime = buf1.st_atime;
- ftime.modtime = buf1.st_mtime;
- (void) utime(output, &ftime);
- }
- else
- (void) fprintf(stderr,
- " %s is up to date.\n", entry->d_name);
- }
- }
- else
- copyerr(6, entry->d_name);
- }
- (void) closedir(dirp);
- }
- else
- {
- va_start(parm);
- file = va_arg(parm, char *);
- for (I = 0; I < count; I++)
- {
- file = va_arg(parm, char *);
- if (source != NULL)
- (void) sprintf(input, "%s/%s", source, file);
- else
- (void) strcpy(input, file);
- if (single)
- (void) strcpy(output, target);
- else
- (void) sprintf(output, "%s/%s", target, file);
- if (stat(input, &buf1) != 0)
- copyerr(6, file);
- docopy = FALSE;
- if (stat(output, &buf2) == 0)
- {
- if (buf1.st_mtime > buf2.st_mtime)
- docopy = TRUE;
- }
- else
- if (errno == ENOENT)
- docopy = TRUE;
- else
- copyerr(3, single?target:file);
- if (docopy)
- {
- if ((fdin = open(input, O_RDONLY)) < 0)
- copyerr(2, file);
- if ((fdout = open(output,
- O_CREAT | O_WRONLY | O_TRUNC, buf1.st_mode)) < 0)
- copyerr(3, single?target:file);
- while ((size = read(fdin, buffer, BUFSIZE)) > 0)
- if (write(fdout, buffer, size) != size)
- copyerr(4, file);
- if (size < 0)
- copyerr(5, single?target:file);
- if (single)
- {
- if ((name = strrchr(target, '/')) == NULL)
- name = target;
- else
- name++;
- }
- else
- name = file;
- (void) fprintf(stderr,
- " Copying %s . . .\n", name);
- (void) close(fdin);
- (void) close(fdout);
- ftime.actime = buf1.st_atime;
- ftime.modtime = buf1.st_mtime;
- (void) utime(output, &ftime);
- }
- else
- {
- if (single)
- {
- if ((name = strrchr(target, '/')) == NULL)
- name = target;
- else
- name++;
- }
- else
- name = file;
- (void) fprintf(stderr,
- " %s is up to date.\n", name);
- }
- }
- va_end(parm);
- }
- return;
- }
-
- static void copyerr(which, name)
- int which;
- char *name;
- {
- char line[MAXLINESIZE];
-
- switch (which)
- {
- case 1:
- (void) sprintf(line, "unable to open directory \"%s\"", name);
- break;
- case 2:
- (void) sprintf(line, "unable to open file \"%s\" for reading", name);
- break;
- case 3:
- (void) sprintf(line, "unable to open file \"%s\" for writing", name);
- break;
- case 4:
- (void) sprintf(line, "error writing file \"%s\"", name);
- break;
- case 5:
- (void) sprintf(line, "error reading file \"%s\"", name);
- break;
- case 6:
- (void) sprintf(line, "file \"%s\" does not exist", name);
- break;
- }
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 9: %s\n Contact dino@cs.colorado.edu for help\n\n",
- line);
- exit(1);
- }
-
- /****************************************************************
- *
- * Makes a directory unless it already exists. Takes a name of
- * a directory, a relative path to that directory and the
- * absolute path of the current directory. The latter two
- * can be NULL.
- *
- ***************************************************************/
-
- static void maked(name, relative, absolute)
- char *name;
- char *relative;
- char *absolute;
- {
- char dir[MAXPATHLEN];
- int mask = S_IRWXU | S_IRWXG | S_IRWXO;
- struct stat buf;
-
- if (absolute == NULL)
- {
- if (relative == NULL)
- (void) strcpy(dir, name);
- else
- (void) sprintf(dir, "%s/%s", relative, name);
- }
- else
- {
- if (relative == NULL)
- (void) sprintf(dir, "%s/%s", absolute, name);
- else
- (void) sprintf(dir, "%s/%s/%s", absolute, relative, name);
- }
- if (stat(dir, &buf) != 0)
- {
- if (errno == ENOENT)
- {
- if (mkdir(dir, mask) != 0)
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 8 (%s): Contact dino@cs.colorado.edu for help\n\n", name);
- exit(1);
- }
- (void) fprintf(stderr,
- "\n Creating directory \"%s\". . .\n", name);
- }
- else
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 8 (%s): Contact dino@cs.colorado.edu for help\n\n, name");
- exit(1);
- }
- }
- else
- {
- if (! S_ISDIR(buf.st_mode))
- {
- (void) fprintf(stderr,
- "\n\nFATAL SYSTEM ERROR 8 (%s): Contact dino@cs.colorado.edu for help\n\n, name");
- exit(1);
- }
- else
- (void) fprintf(stderr,
- "\n Directory \"%s\" already exists.\n", name);
- }
- return;
- }
-